package com.zhuiyun.project.api.apppatient.mapper;

import com.zhuiyun.project.api.apppatient.entity.Patient;
import com.zhuiyun.project.common.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @ClassName PatientMapper
 * @Description TODO
 * @Author Root
 * @Date 2023/7/3 9:50
 **/
@Mapper
public interface PatientMapper extends BaseMapper<Patient> {
    @Select("select * from app_patient where user_id = #{userId} and cycle = #{cycle} and disease = #{disease} order by user_birthday")
    List<Patient> getPatientByName(Integer userId,String cycle,String disease);
    @Select("select * from app_patient where user_id = #{userId} and cycle = '第一周期'")
    List<Patient> getPatientByCycle1(Integer userId);
    @Select("select * from app_patient where user_id = #{userId} and cycle = '第二周期'")
    List<Patient> getPatientByCycle2(Integer userId);

    @Select("select * from app_patient where user_id = #{userId} and cycle = '第三周期'")
    List<Patient> getPatientByCycle3(Integer userId);
    @Select("select * from app_patient where user_id = #{userId} and cycle = '第四周期'")
    List<Patient> getPatientByCycle4(Integer userId);

    @Update("update app_patient set name = #{newName} where name = #{name}")
    Integer updatePatientByName(String name,String newName);
    @Update("update app_patient set open = #{open} where user_id = #{userId} and cycle = #{cycle} and disease = #{disease}")
    Integer updatePatientById(Patient patient);
}
